<?php 
include_once 'inc/config.php';
include_once 'inc/mysql.class.php';
include_once 'smrty.php';
$mysql = new mysql();
$mysql->open($dbconfig);
//查询订单
if ($_GET['do']=="s") {
	if (!isset($_GET['id'])) {
		$order = $mysql->select("*", "order");
		$smarty->assign('orderlist',$order);
		$smarty->display('order_list.html');
		
	}else {
		$order = $mysql->select("*", "order","`id`=$_GET[id]");
		$smarty->assign('orderlist',$order);
		$smarty->display('order_list.html');
	}
}elseif ($_GET['do']=="edit"){
	if ($_POST[submit]) {
		$data=array();
		if ($_POST[huohao])$data[huohao]=$_POST[huohao];
		if ($_POST[kuanhao])$data[kuanhao]=$_POST[kuanhao];
		if ($_POST[pinming])$data[pinming]=$_POST[pinming];
		if ($_POST[zhuangxiangshu])$data[zhuangxiangshu]=$_POST[zhuangxiangshu];
		if ($_POST[newdate])$data[newdate]=$_POST[newdate];
		if ($mysql->update($data, "order","`id`=$_POST[id]")) {
		echo "<script language='javascript'>location='order.php?do=s&id=$_POST[id]';</script>";}else {echo "更新失败";}
	}else {
		if ($_GET['id']!=""){
			$order = $mysql->get_one("*", "order","`id`=$_GET[id]");
			$smarty->assign('order',$order);
			$smarty->display('order.html');				
		}
	}	
}elseif ($_GET['do']=="add"){
	if ($_POST[submit]) {
		$data=array();
		if ($_POST[huohao])$data[huohao]=$_POST[huohao];
		if ($_POST[kuanhao])$data[kuanhao]=$_POST[kuanhao];
		if ($_POST[pinming])$data[pinming]=$_POST[pinming];
		if ($_POST[zhuangxiangshu])$data[zhuangxiangshu]=$_POST[zhuangxiangshu];
		if ($_POST[newdate])$data[newdate]=$_POST[newdate];
		if ($mysql->insert($data, "order")) {
		echo "<script language='javascript'>location='order.php?do=s';</script>";}else{echo "添加失败";}
	}else {
			$smarty->display('order_add.html');			
	};
}elseif ($_GET['do']=="del"){
	;
}
?>
